<style type="text/css">
    .title-left a{color:#888;}
    .title-left .active{color:#009997;}
</style>
<div class="comm-top">
	<div class="title-left">群发素材列表</div>
	<div class="title-right">
    <form method="get" action="">选择群发分组
        <select class="textarea" id="qunfa_group" style="border-radius:3px;">
            <option value="-1">全部分组</option>
        </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="keyword" class="textarea search_inp" placeholder="请输入标题" type="text" value="<{$smarty.get.keyword}>"/>
        <input value="搜索" class="btn btn-success search_btn" type="submit" />
        <input value="添加<{$cateName}>" class="btn btn-success search_btn" type="button" onclick="location.href='multi.php?a=add'">
    </form>
	</div>
</div>
<div class="list-table">
	<div class="wrapper">
		<table class="stable">
			<thead>
				<tr>
					<th>主图文标题</th>
					<th>图文数</th>
					<th>状态</th>
					<th>发送时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
                <form id="memberForm">
                <{foreach from=$list item=v}>
					<tr>
						<td><{$v.info_title}></td>
						<td><{$v.item_num|default:0}></td>
						<{if $v.is_send==1}><td style="color:#009997;font-weight:bold;">已发送</td><{else}><td style="color:red">未发送</td><{/if}>
						<td><{if $v.send_time}><{$v.send_time|date_format:"%Y-%m-%d %H:%M"}><{else}>-<{/if}></td>
						<td><div class="btn-operate">
                            <a href="multi.php?a=edit&id=<{$v.id}>" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
                            <a href="javascript:void(0);" onclick="delRow('<{$v.id}>',this)" title="删除" id="delBtn<{$v.id}>"><i class="glyphicon glyphicon-trash"></i></a>
                            <{if $suserSession.type==3}>
                            <a href="javascript:void(0);" onclick="send(<{$v.id}>,this)" id="sendBtn<{$v.id}>" style="font-size:14px;color:#009997;">群发</a>
                            <{else}>
                            <a href="bunch_send.php?id=<{$v.id}>&customer_id=<{$suserSession.id}>&cus_type=<{$suserSession.type}>" target="_blank" style="font-size:14px;color:#009997;">群发</a>
                            <{/if}>
                        </div></td>
					</tr>
                <{/foreach}>
                </form>
			</tbody>
		</table>
	</div>
</div>
<{if $page}><div class="page-list"><{$page}></div><{/if}>
<script type="text/javascript">
//页面加载完后加载分组
$(function(){
    $.post('push.php',{a:'get_group'},function(res){
        var optionStr='';
        $.each(res,function(i,n){
            optionStr+='<option value="'+n.id+'">'+n.name+'</option>';
        })
        $('#qunfa_group').append(optionStr);
    },'json');
});
//删除
function delRow(id,obj){
    if(confirm('确定要删除吗？')){
        $.post('multi.php',{a:'del',id:id},function(res){
            res=$.trim(res);
            if(res=='suc'){
                note_info('删除成功',obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info(res,obj,'warn');
            }
        });
    }
}
//发送
function send(id,obj){
    if(confirm('确定要群发此素材吗？')){
        var layerLoad=layer.load(1,{shade:[0.1,'#666']});
        $.post('push.php',{a:'sendMulti',id:id,groupid:$('#qunfa_group').val()},function(res){
            layer.close(layerLoad);
            if(res=='suc'){
                note_info('群发请求已发送成功',obj);
                setTimeout('window.location.reload()',1500);
            }else{
                note_info(res,obj,'warn');
            }
        },'json');
    }
}
</script>